/*
 * ECARX Technology Limited is the owner of the copyright and the trade secret of this software.
 * Without permission, no one has the right to obtain, disclose or use this software in any way.
 */

package com.ecarx.systemui.plugin.model.wifi;

import com.ecarx.systemui.plugin.R;
import com.ecarx.systemui.plugin.utils.WifiUtils;

import java.util.Objects;

public class WifiItemBean {

    public int index;
    public String name;
    public boolean locked;
    public int signal;
    public String ip;
    public String speed;
    public String mac;
//    public String level;
    public String ssid;
    public WifiUtils.WifiCapability lockType = WifiUtils.WifiCapability.WIFI_NONE;
    public String BSSID;
    public String password;

    public String convertIndex(int index) {
        if (index < 10) {
            return "0" + (index + 1);
        }
        return String.valueOf((index + 1));
    }

    public int convertSignal() {
        if (signal == 0) {
            return R.drawable.wifi_gray_0;
        }
        if (signal == 1) {
            return R.drawable.wifi_gray_1;
        }
        if (signal == 2) {
            return R.drawable.wifi_gray_2;
        }
        if (signal == 3) {
            return R.drawable.wifi_gray_3;
        }
        return R.drawable.wifi_gray_4;
    }
    public int convertColorSignal() {
        if (signal == 0) {
            return R.drawable.wifi_color_0_svg;
        }
        if (signal == 1) {
            return R.drawable.wifi_color_1_svg;
        }
        if (signal == 2) {
            return R.drawable.wifi_color_2_svg;
        }
        if (signal == 3) {
            return R.drawable.wifi_color_3_svg;
        }
        return R.drawable.wifi_color_4_svg;
    }

    @Override
    public String toString() {
        return "WifiItemBean{" +
                "index=" + index +
                ", name='" + name + '\'' +
                ", lock=" + locked +
                ", signal=" + signal +
                ", ip='" + ip + '\'' +
                ", speed='" + speed + '\'' +
                ", mac='" + mac + '\'' +
                ", BSSID='" + BSSID + '\'' +
                ", ssid='" + ssid + '\'' +
                ", password='" + password + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        WifiItemBean bean = (WifiItemBean) o;
        return Objects.equals(name, bean.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(index, name, locked, signal, ip, speed, mac, ssid);
    }
}
